{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "initial_id",
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# -*- coding: utf-8 -*-\n",
    "import os\n",
    "import socket\n",
    "import platform\n",
    "import sys\n",
    "\n",
    "def systemInfo():\n",
    "    system = os.popen(\"cat /etc/os-release|grep -E \\\"^NAME\\\"|awk -F \\\"\\\\\\\"\\\" '{print $2}'\").readline()\n",
    "    sysversion = os.popen(\"cat /etc/os-release|grep -E \\\"^VERSION\\\"|awk -F \\\"\\\\\\\"\\\" '{print $2}'\").readline()\n",
    "    hostname = platform.node()\n",
    "    version = platform.release()\n",
    "    framework = platform.machine()\n",
    "    cpumodel = os.popen(\"cat /proc/cpuinfo |grep \\\"model name\\\"|awk -F : '{print $2}'\").readline()\n",
    "    cpucores = os.popen('grep \"processor\" /proc/cpuinfo |wc -l').readline()\n",
    "    memory = os.popen(\"cat /proc/meminfo |grep MemTotal|awk '{print $2$3}'\").readline()\n",
    "    swapmemory = os.popen(\"cat /proc/meminfo |grep SwapTotal|awk '{print $2$3}'\").readline()\n",
    "    ip_address = socket.gethostbyname(socket.gethostname())\n",
    "\n",
    "    # 获取 Python 版本\n",
    "    python_version = sys.version\n",
    "    python_version_info = sys.version_info\n",
    "\n",
    "    # 获取 Python 解释器信息\n",
    "    python_implementation = platform.python_implementation()\n",
    "\n",
    "    # 获取 Python 可执行文件路径\n",
    "    python_executable = sys.executable\n",
    "\n",
    "    # 获取 Python 安装路径\n",
    "    python_lib_path = sys.prefix\n",
    "\n",
    "    # 获取 Python 编译器信息\n",
    "    compiler = platform.python_compiler()\n",
    "\n",
    "    print(['系统名称',system.replace('\\n','')])\n",
    "    print(['系统版本',sysversion.replace('\\n','')])\n",
    "    print(['主机名',hostname])\n",
    "    print(['内核版本',version])\n",
    "    print(['CPU架构',framework])\n",
    "    print(['CPU型号',cpumodel.replace('\\n','')])\n",
    "    print(['CPU核心数',cpucores.replace('\\n','')])\n",
    "    print(['物理内存',memory.replace('\\n','')])\n",
    "    print(['交换空间',swapmemory.replace('\\n','')])\n",
    "    print(['ip地址',ip_address.replace('\\n','')])\n",
    "    print(\"Python 版本:\", python_version)\n",
    "    print(\"Python 版本信息:\", python_version_info)\n",
    "    print(\"Python 解释器:\", python_implementation)\n",
    "    print(\"Python 可执行文件路径:\", python_executable)\n",
    "    print(\"Python 安装路径:\", python_lib_path)\n",
    "    print(\"Python 编译器:\", compiler)\n",
    "\n",
    "\n",
    "systemInfo()\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
